package com.android.lovingpet.signin;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;


import com.android.lovingpet.SignModel;
import com.android.lovingpet.base.BasePresenter;
import com.android.lovingpet.common.Back;


/**
 * Created by ikata on 2018/2/6.
 */

public class SignInPresenter extends BasePresenter<ISignInContract.View> implements ISignInContract.Presenter{
    private SignModel sign_in_model;
    public SignInPresenter() {
        sign_in_model=new SignModel();
    }
    public void sign_in(final String userName,final String userPassword, int userType) {
        if (TextUtils.isEmpty(userName) || userName.length() != 11 ||
                TextUtils.isEmpty(userPassword) || userPassword.length() < 6) {
            getView().showToast("帐号或密码错误!");
            return;
        }
        getView().showProgress();
        sign_in_model.sign(1, userName, userPassword, userType, new Back() {
            @Override
            public void onFailure(String msg) {
                getView().hideProgress();
                getView().showToast(msg);
            }

            @Override
            public void onSuccess(@Nullable Bundle bundle) {
                getView().next();
            }
        });
    }
}
